package com.iias.data.pool;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DataPool {

    private static DataSource DATA_SOURCE = null;

    public static void setDataSource(DataSource dataSource){
        DATA_SOURCE = dataSource;
    }

    public static Connection getConnection(){
        try {
            return DATA_SOURCE.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }


    public static void release(Connection connection){
        try {
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
